package cn.com.wdjedu.androidapp.wjeduandroid.support.lib.utils;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.mrjian.banner.CBPageAdapter;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * Created by Sai on 15/8/4.
 * 网络图片加载例子
 */
public class NetworkImageHolderView implements CBPageAdapter.Holder<String> {
    private ImageView imageView;

    public NetworkImageHolderView() {
    }

    @Override
    public View createView(Context context) {
        //你可以通过layout文件来创建，也可以像我一样用代码创建，不一定是Image，任何控件都可以进行翻页
        imageView = new ImageView(context);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);

//        networkImageView = new NetworkImageView(context);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

//        networkImageView.setLayoutParams(layoutParams);
//        CBLoopViewPager.LayoutParams
//        networkImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        return imageView;
    }

    @Override
    public void UpdateUI(final Context context, final int position, final String data) {
//        imageView.setImageResource(R.drawable.icon);
//        networkImageView.setDefaultImageResId(R.drawable.bigimage);
//        networkImageView.setImageResource(R.drawable.bigimage);
//        if (!TextUtils.isEmpty(data)){
//            ImageLoader.getInstance().displayImage(data,networkImageView);
//        }


//        Log.d("print",networkImageView.getParent().toString());

        ImageLoader.getInstance().displayImage(data, imageView);
        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
            }
        });
    }
}
